package com.taxsystem.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.main.taxsystem.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class TaxPolicyGuide extends Activity{
	
	private static final String[] itemText = {"政务公开","纳税辅导","税务政策","热点问题"};

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.grid_view);
	      List<Map<String, Object>> items = new ArrayList<Map<String,Object>>();

	        for (int i = 0; i < 4; i++) {

	          Map<String, Object> item = new HashMap<String, Object>();

	          item.put("imageItem", R.drawable.temp_logo);

	          item.put("textItem", itemText[i]);

	          items.add(item);

	        }
	        SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.grid_item, new String[]{"imageItem", "textItem"}, new int[]{R.id.image_item, R.id.text_item});
	        GridView gridview = (GridView)findViewById(R.id.mygridview);
	        gridview.setAdapter(adapter);

	        gridview.setOnItemClickListener(new OnItemClickListener()
			{
				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id)
				{
					switch ((int)id)
					{
						case 0:
							Toast toast1 = Toast.makeText(getApplicationContext(),
								     String.valueOf(id), Toast.LENGTH_SHORT);
							toast1.show();
							break;
						case 1:
							Toast toast2 = Toast.makeText(getApplicationContext(),
								     String.valueOf(id), Toast.LENGTH_SHORT);
							toast2.show();
							break;
						case 2:
							Toast toast3 = Toast.makeText(getApplicationContext(),
								     String.valueOf(id), Toast.LENGTH_SHORT);
							toast3.show();
							break;
						case 3:
							Toast toast4 = Toast.makeText(getApplicationContext(),
								     String.valueOf(id), Toast.LENGTH_SHORT);
							toast4.show();
							break;	
					}
				}

			});

	}

}
